Class sjl.ReverseBidirectionalIterator
All Packages Class Hierarchy This Package Previous Next Index
Class sjl.ReverseBidirectionalIterator
java.lang.Object
|
+----sjl.Iter
|
+----sjl.ReverseBidirectionalIterator
- public class ReverseBidirectionalIterator
- extends Iter
- implements BidirectionalIterator
ReverseBidirectionalIterator
is an iterator adapter that
will traverse the container in the reverse order of an ordinary
BidirectionalIterator
.
BidirectionalIterator iter = new ReverseBidirectionalIterator(coll.end());
for (; i.cmp(coll.begin()); i.next()) { ... }
The same functionallity can be found with.
for (BidirectionalIterator iter = coll.rend(); i.cmp(coll.rbegin()); i.next()) { ... }
Any BidirectionalIterator
"iter" can be turned into a
reverse iterator with:
Bidirectional reverse_iter = Iter.reverse(iter);
XXX: Not true.
Copyright © 1996 Finn Bock
-
ReverseBidirectionalIterator(BidirectionalIterator)
- Contruct a ReverseBidirectionalIterator for the iterator.
-
cmp(Iterator)
- Compares two iterators.
-
distance(Iterator)
- Returns the distance between two iterators.
-
genericCopy()
- Create a copy of the this.
-
get()
- Return the current value pointed to by the iterator.
-
next()
- Advance the iterator to the next element.
-
prev()
- Advance the iterator to the previous element.
-
put(Object)
- Places a new element in the position pointed to by the iterator.
-
setTo(Iterator)
- Assign this iterator to another iterator.
ReverseBidirectionalIterator
public ReverseBidirectionalIterator(BidirectionalIterator iter)
- Contruct a ReverseBidirectionalIterator for the iterator.
The newly contructed iterator will have a reference to the
argument iterator.
Each time next() and prev() is called on the
ReverseBidirectionalIterator, the argument iterator is move back
and forward.
- Parameters:
- iter - A BidirectionalIterator.
genericCopy
public Iterator genericCopy()
- Create a copy of the this. The copy can then be moved without
affecting this.
- Returns:
- A new iterator pointing to the same element as this.
setTo
public void setTo(Iterator i)
- Assign this iterator to another iterator. This is faster than creating
a new ReverseBidirectionalIterator object.
next
public Iterator next()
- Advance the iterator to the next element. Calls
prev()
on the actual iterator.
prev
public Iterator prev()
- Advance the iterator to the previous element. Calls
next()
on the actual iterator.
get
public Object get()
- Return the current value pointed to by the iterator.
put
public Object put(Object o)
- Places a new element in the position pointed to by the iterator.
cmp
public boolean cmp(Iterator i)
- Compares two iterators.
- Returns:
- true if the iterators point to the same position.
distance
public int distance(Iterator i)
- Returns the distance between two iterators.
All Packages Class Hierarchy This Package Previous Next Index